1. Technical Field
This invention generally relates to the optimization of computer programs, and more specifically relates to a computer apparatus and method for determining the order of program portions in a computer program.
2. Background Art
The development of the EDVAC computer system in 1948 is generally considered the beginning of the computer era. Since that time, dramatic advances in both hardware and software (e.g., computer programs) have drastically improved the performance of computer systems. Modern software has become very complex when compared to early computer programs. Many modern computer programs have tens or hundreds of thousands of instructions. The execution time (and hence, performance) of a computer program is very closely related to the number of instructions that are executed as the computer program runs. Thus, as the size and complexity of computer programs increase, the execution time of the computer program increases as well.
Unlike early computer programs, modern computer programs are typically written in a high-level language that is easy to understand by a human programmer. Special software tools known as compilers take the human-readable form of a computer program, known as "source code", and convert it into "machine code" or "object code" instructions that may be executed by a computer system. Because a compiler generates the stream of machine code instructions that are eventually executed on a computer system, the manner in which the compiler converts the source code to object code affects the execution time of the computer program.
The execution time of a computer program, especially complex computer programs, is a function of the arrangement and type of instructions within the computer program. Branch instructions are one type of instruction that may affect the execution time of a computer program. A branch instruction may cause the processor to go (i.e., branch) to a different part of the computer program to execute instructions. If a computer program contains many branch instructions, the time spent branching from one portion of the program to the next may introduce delays. Judicious selection of the order of portions of the computer program may improve the program's execution time by placing portions that are executed sequentially in sequential order.
In order to optimize the performance of modern computer programs, profilers have been developed to predict and/or measure the run-time performance of a computer program. Profilers typically generate profile data that estimates how often different portions of the computer program are executed. Using profile data, an optimizer (such as an optimizing compiler) may make decisions regarding the preferred order of different portions of the computer program in order to optimize the execution speed of the computer program.
Known prior art systems generate profile data that is used by a compiler to determine the order of portions of a computer program. However, the known methods for using profile data in reordering portions of a computer program do not provide an optimal solution. Prior art methods may still yield inefficiencies in the structure of the code, such as taking branches along the most frequently executed path, that result in a slower execution time for the computer program. Without improved apparatus and methods for reordering portions of a computer program based on profile data, the performance of the computer program will be less optimized.